package com.tul.exercise.base.string.format;

import java.util.Random;

import static com.tul.exercise.base.utils.Print.*;

/**
 * @Description 《java编程思想》第13章 示例3：
 * <p>
 * 循环String连接时，使用StringBuilder
 **/
public class UsingStringBuilder {
    public static Random rand = new Random(47);

    public String toStirng() {
        StringBuilder result = new StringBuilder("[");
        for (int i = 0; i < 25; i++) {
            result.append(rand.nextInt(100));
            result.append(", ");
        }
        result.delete(result.length() - 2, result.length());
        result.append("]");
        return result.toString();
    }

    public static void main(String[] args) {
        UsingStringBuilder usb = new UsingStringBuilder();
        print(usb.toStirng());
    }

}








